<?php
//引入初始化文件
include '../init.php';
//引入数据库文件
include DIR_CORE . 'mysql.php';

$title = '沐水莲心-成绩排名';

// 判断用户是否登录
login();

//提取score表总的数据信息
$ssql = "select count(*) as sum from score";
$sres = mysqli_query($link, $ssql);
$srow = mysqli_fetch_assoc($sres);

//var_dump($srow);

$rowCount = $srow['sum'];

// 得到总记录数

if ($rowCount != 0) {
    $rowsPerPage = 5;
    $maxnum = 5;
    $url = 'list.php';
    
    //载入分页文件
    include DIR_CORE . 'page.php';

    $strPage = page($rowCount, $maxnum, $rowsPerPage, $url);

    $pageNum = isset($_GET['pageNum']) ? $_GET['pageNum'] : 1;

    //提取type表的数据
    $offset = ($pageNum - 1) * $rowsPerPage;
    $sql = "select * from score order by score limit $offset, $rowsPerPage ";
    $res = mysqli_query($link, $sql);
    // 得到资源结果集,
    
    //定义空数组存数据
    $list = array();
    //遍历数据库，取数据
    while ($row = mysqli_fetch_assoc($res)) {
        $list[]=$row;
    }
    //var_dump($list);
} else {
    $strPage = '<h3>信息量不够</h3>';
    echo $strPage;
}



//引入视图文件
include DIR_VIEW .'list.html';
